﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using School.Entities;
namespace School.Pages.Teaching
{
    public partial class TE_Show_Answer : System.Web.UI.Page
    {
        private static SchoolEntities db = new SchoolEntities();
        public long Student_Id;
        protected void Page_Load(object sender, EventArgs e)
        {
            Student_Id = 31;
            //long.Parse(Request.QueryString["Stud_id"].ToString());
            if (!IsPostBack)
                LstSchoolsBind();

        }
        private void LstSchoolsBind()
        {
            long id = long.Parse(Request.QueryString["id"].ToString());
            var qy = from c in db.VTE_Show_Answer where c.Topic_Id == id select c;
            LstSchools.DataSource = qy.ToList();
            LstSchools.DataBind();
        }
        protected void LstSchools_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                string Question_id = LstSchools.DataKeys[e.Item.DataItemIndex].Values["Question_Id"].ToString();
                long q = long.Parse(Question_id);
                Label lblanswer = (Label)e.Item.FindControl("lblanswer");
                var qu = from c in db.Vanswers where c.Question_Id == q && c.Student_Id == Student_Id select c;
                foreach (var item in qu)
                {
                    lblanswer.Text += item.Choices.ToString() + "\r\n";

                }
            }
        }

    }
}